//
//  HomeModalCell.m
//  zjGovernment
//
//  Created by 胡胜冬 on 2017/2/9.
//  Copyright © 2017年 胡胜冬. All rights reserved.
//

#import "HomeModalCell.h"

@interface HomeModalCell ()

@end

@implementation HomeModalCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:self.leftImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.lineView];
    }
    return self;
}

- (void) layoutSubviews {

    [super layoutSubviews];
    [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.contentView.mas_left).offset(20 * m6Scale);
        make.size.mas_equalTo(CGSizeMake(28 * m6Scale, 32 * m6Scale));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.leftImageView.mas_right).offset(20 * m6Scale);
        make.right.mas_equalTo(self.contentView.mas_right).offset(-20 * m6Scale);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.contentView.mas_centerX);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-2 * m6Scale);
        make.size.mas_equalTo(CGSizeMake(self.contentView.frame.size.width - 40 * m6Scale, 2 * m6Scale));
    }];
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = BackgroundColor;
    }
    return _lineView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = RGB(103, 103, 103);
        _titleLabel.font = [UIFont systemFontOfSize:24 * m6Scale];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}


- (UIImageView *)leftImageView {
    if (!_leftImageView) {
        _leftImageView = [[UIImageView alloc] init];
        _leftImageView.clipsToBounds = YES;
        _leftImageView.backgroundColor = [UIColor clearColor];
    }
    return _leftImageView;
}

#pragma mark - 重写 set 方法

- (void)setLineHidden:(BOOL)hidden {
    self.lineView.hidden = hidden;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
